var mapIds = [330006000, 330006100, 330006200];
var 准备地图 = 330001900;

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("副本_好友故事_Act1_寻找希纳斯");
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.killAllMonsters(false)
    }
    return c
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(-100);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(15 * 60 * 1000)
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    em.setProperty("kill", "0");
    em.setProperty("clear", "0");
    em.setProperty("curMap", a)
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(a, b) {
    a.getPlayers().forEach(function (e) {
        var d = em.getNumberProperty("kill") + 1;
        em.setProperty("kill", d);
        var c = e.getMapId();
        if (c == 330006000 && d == 21) {
            e.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
            e.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
            em.setProperty("clear", 1)
        } else {
            if (c == 330006100 && d == 21) {
                e.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                e.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                em.setProperty("clear", 1)
            } else {
                if (c == 330006200 && d == 20) {
                    e.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                    e.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                    em.setProperty("clear", 1)
                }
            }
        }
    });
    return 1
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};